<template>
  <div class="banner">
    Categories
  </div>
  <br>
  <el-row>
    <el-col :span="4"></el-col>
    <el-col :span="16">
      <el-space wrap size="large">
        <el-card v-for="item in categories" style="width: 250px;height: 250px"
                 :body-style="{padding:'0px'}"
                 @click="toShow(item.categoryId)">
          <template #header>
            <el-link>{{ item.categoryName }}</el-link>
            <el-tag style="float: right">{{ item.blogCount }} 篇内容</el-tag>
          </template>
          <el-image :src="item.categoryIcon" fit="cover" style="width: 250px;height: 180px"></el-image>
        </el-card>
      </el-space>
    </el-col>
    <el-col :span="4"></el-col>
  </el-row>
  <br>
</template>

<script>
export default {
  name: "Category",
  async created() {
    let {data} = await this.$http.get("/api/category/getAllUseCategories")
    console.log(data)
    this.categories = data
  },
  data() {
    return {
      categories: [],
    }
  },
  methods: {
    toShow(categoryId) {
      this.$router.push({path: "/categories/" + categoryId})
    }
  }
}
</script>

<style scoped>
.banner {
  background-image: url('/headImg/category.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  height: 400px;
  width: 100%;

  color: white;
  font-size: 3em;
  font-weight: bolder;
  text-align: center;
  padding-top: 200px;
}

p, h3, h4 {
  line-height: 2;
}
</style>